﻿@*
    列表视图 - 卡片模式(卡片页脚)
*@
@using NewLife;
@using Microsoft.AspNetCore.Routing
@using NewLife.Cube.Entity
@using XCode;
@using XCode.Configuration;
@using XCode.Membership;
@{
    var entity = Model as IEntity;

    var set = ViewBag.PageSetting as PageSetting ?? PageSetting.Global;
    var rv = entity.GetRouteKey();
}

<div class="card-footer d-flex justify-content-end py-5">
    @if (set.IsReadOnly)
    {
        if (this.Has(PermissionFlags.Detail))
        {
            <a href="@Url.Action("Detail", rv)" class="btn btn-sm btn-icon btn-light-primary btn-active-primary" data-bs-toggle="tooltip" title="查看">
                <i class="fas fa-file-alt fs-4"></i>
            </a>
        }
    }
    else if (this.Has(PermissionFlags.Update))
    {
        <a href="@Url.Action("Edit", rv)" class="btn btn-sm btn-icon btn-light-primary btn-active-primary me-2" data-bs-toggle="tooltip" title="编辑">
            <i class="fas fa-edit fs-4"></i>
        </a>
    }
    else if (this.Has(PermissionFlags.Detail))
    {
        <a href="@Url.Action("Detail", rv)" class="btn btn-sm btn-icon btn-light-primary btn-active-primary me-2" data-bs-toggle="tooltip" title="查看">
            <i class="fas fa-file-alt fs-4"></i>
        </a>
    }

    @if (this.Has(PermissionFlags.Delete))
    {
        var fact = ViewBag.Factory as IEntityFactory;
        var fi = (fact == null || fact.Fields == null) ? null : fact.Fields.FirstOrDefault(e => e.Name.EqualIgnoreCase("Deleted", "IsDelete", "IsDeleted"));
        if (fi != null && fi.Type == typeof(Boolean) && (Boolean)entity[fi.Name])
        {
            <a data-bs-toggle="tooltip" title="恢复" class="btn btn-sm btn-icon btn-light-success btn-active-success me-2" data-url="@Url.Action("Delete", rv)" data-type="warning" data-title="确认恢复？">
                <i class="fas fa-trash-alt fs-4"></i>
            </a>
        }
        else
        {
            <a data-bs-toggle="tooltip" title="删除" class="btn btn-sm btn-icon btn-light-danger btn-active-danger swal_tip me-2" data-url="@Url.Action("Delete", rv)" data-type="error" data-title="确认删除？">
                <i class="fas fa-trash-alt fs-4"></i>
            </a>
        }
    }

    @await Html.PartialAsync("_List_Data_Action_Adv", entity)
</div>